import socket
tcp_server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
tcp_server_socket.bind(('127.0.0.1',8888))
tcp_server_socket.listen(128)
print("--------服务端开启，等待客户接入--------------")
tcp_client,client_addr = tcp_server_socket.accept()
print("有新的客户端接入",client_addr)
while True:
    client_data = tcp_client.recv(1024)
    if client_data:

        print("client_data:", client_data.decode("utf-8"))
        tcp_client.send("消息已收到".encode("utf-8"))
    else:
        print(f"客户端{client_addr}已断开连接")
        tcp_client.close()
        break
tcp_server_socket.close()
